<?php

	include_once "include/commons/IncludeWrapper.php";
	
	class BotProcess {
		static private $instance;
		static private $planetas;
		static private $bot;
		
		private function __construct() {
			self::$bot = new Bot();
			self::$planetas = array();
			
			for( $i=1; $i <= 15; $i++ ) {
				$planeta = new Planeta(2, 10, $i, self::$bot->getId());
				$planeta->setUsuario("Livre");
				array_push( self::$planetas, $planeta ); 	
			}
		}
		
		static public function getInstance() {
			if ( !isset( self::$instance ) ) {
            	$c = __CLASS__;
           		self::$instance = new $c;
        	}
        	return self::$instance;
		}
		
		public function take($slot) {
			for( $i=1; $i <= 15; $i++ ) {
				if ( self::$planetas[i]->getSlot() == $) 	
			}
			
			
			
			if( array_key_exists( $slot, self::$planetas ) ) {
				$planeta = self::$planetas[$slot];
				$planeta->setUsuario("Marcio");
				echo " First time " . $planeta->toJSONObject();
				self::$planetas[$slot] = $planeta;
				echo " Second time " . self::$planetas[$slot]->toJSONObject();	
			} else {
				echo "key nao existe";
			}
		}
		
		public function drop($slot) {
			$planeta = self::$planetas[$slot];
			$planeta->setUsuario("Livre");
			self::$planetas[$slot] = $planeta;
		}
		
		public function getPlanetas() {
			return self::$planetas;
		}
	}
?>